<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>日志信息</span>
        <el-button style="float: right; padding: 3px 0" @click="$router.push({path:'access_log'})" type="text">返回</el-button>
      </div>
      <div v-for="(item,index) in form" :key="index" class="text item">
       <span class="item-title">{{index}}</span>： {{ item }}
      </div>
    </el-card>
  </div>
</template>

<script>
import api from '@/api/access_log'

export default {
  components: {},
  data() {
    return {

      form: {
        id: 0

      }

    }
  },

  mounted() {
    if (this.$route.query.hasOwnProperty('id')) {
      this.getData(this.$route.query.id)
    }
  },

  methods: {
    getData(id) {
      api.info({ id: id }).then((res) => {
        this.form = res.data
      })
    },
    onSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          let req
          if (this.form.id > 0) {
            req = api.update(this.form)
          } else {
            req = api.create(this.form)
          }
          req.then((res) => {
            this.$message({
              type: 'success',
              message: res.msg,
              duration: 500,
              onClose: () => {
                this.$router.push({ path: 'access_log' })
              }
            })

          }).catch((error) => {

          })
        }
      })

    }
  }
}
</script>

<style scoped>
.text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 100%;
  }
.item-title{
  font-weight: bold;
}
</style>

